<%@ page language="java" import="com.util.StringFinal" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%
	String userid = request.getSession().getAttribute("user_id") == null
			? ""
			: request.getSession().getAttribute("user_id").toString();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="../../css/index.css" />
<link rel="stylesheet" type="text/css" href="../../css/personal.css" />
<link rel="stylesheet" type="text/css" href="../../css/background.css" />
<link rel="stylesheet" type="text/css" href="../../css/upload/fileinput.css" />

<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="../../js/upload/fileinput.js"></script>
<script type="text/javascript" src="../../js/login/jquery.form.min.js"></script>

<link rel="stylesheet" type="text/css" href="../../css/bootstrapValidator.min.css" />
<script type="text/javascript" src="../../js/bootstrapValidator.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="../../bootstrap-3.3.7/docs/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script type="text/javascript" src="../../js/wordcontrol.js"></script>
</head>
<body>
	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12" style="padding-bottom: 10px">
				<%@include file="../common/header.jsp"%>
			</div>
		</div>
		<input type="text" id="zjid" value="<%=request.getParameter("zjid")%>" hidden="true"> 
		<input type="text" id="zjname" value="<%=request.getParameter("zjname")%>" hidden="true">
		<div class="col-md-1"></div>
		<div class="col-md-10">
			<p style="line-height: 300%; font-size: 160%;">
				您正在给专家<%=request.getParameter("zjname")%>留言提问：
			</p>
			<p style="line-height: 300%;">主题：</p>
			<input class="form-control" type="text" style="" readonly" class="" id="abstract" name="abstract">
			<p style="line-height: 300%;">问题内容：</p>
			<textarea rows="9" cols="126" style="width: 100%; overflow: auto; word-break: break-all;" placeholder="请输入您的意见" id="content"
			onKeyUp="ControlWordCount(&quot;content&quot;,&quot;count&quot;,<%=StringFinal.message_length%>)"></textarea>
			<button type="button" class="btn btn-default" onclick="addMessage()" style="float: right; margin: 15px;">提问</button>
			<p style="float: right; margin-top: 5px">
				你还可以输入<span id="count"><%=StringFinal.message_length%></span>个字
			</p>
		</div>
		<div class="col-md-1"></div>
		<div class="row clearfix">
			<div class="col-md-12" style="padding-bottom: 10px">
				<%@include file="../common/bottom.jsp"%>
			</div>
		</div>
	</div>
</body>
<script>
	function addMessage(){
		var userid = '<%=userid%>';
		if (userid != "") {
			if ($('#abstract').val() == "") {
				alert("请输入您的主题！");
				return;
			}
			if ($('#content').val() == "") {
				alert("请输入您的问题！");
				return;
			}
			$.ajax({
				url : '../message/addMessage',
				type : 'post',
				async : false,
				data : {
					user_id : userid,
					touser_id : $('#zjid').val(),
					message_content : $('#content').val().replace(/ /g,"&nbsp").replace(/[\n\r]/g, "<br>"),
					message_abstract : $('#abstract').val(),
					message_open : "公开"
				},
				success : function(result) {
					if (result != 0) {
						$('#content').val("");
						$('#abstract').val("");
						alert("提交成功");
					} else {
						$('#content').val("");
						$('#abstract').val("");
						alert("提交失败");
					}
				}
			});
		} else {
			alert("请您先登录");
		}
	}
</script>
</html>